//============================================================================
// Name        : RFLab.cpp
// Author      : dodge
// Version     :
// Copyright   : Guangcheng Pu copyright.
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string.h>
using namespace std;
#include "WirelessLab.h"

int main(int argc, char **argv) {
  if (argc < 2) {
    fprintf(stderr, "usage: -f:find device; -s:setdata -g:getdata\n");
    exit(1);
  }

  WirelessLab * RFLab = new WirelessLab();
  
  if (strcmp(argv[1],"-f")==0)
  {
	  RFLab->RFfinddevice(0x0C);
  }else if (strcmp(argv[1],"-s")==0)
  {
	  char data[4];
	  
	  if (argc>1) data[0]=(char)atoi(argv[2]);
	  if (argc>2) data[1]=(char)atoi(argv[3]);
	  if (argc>3) data[2]=(char)atoi(argv[4]);
	  if (argc>4) data[3]=(char)atoi(argv[5]);
	  RFLab->RFsetdata(0x0c,data,4);
  }else if (strcmp(argv[1],"-g")==0)
  {
	  unsigned char i;
	  char buffer[8];
	  RFLab->RFgetdata(0x0c,buffer,sizeof(buffer));
	  for(i=0;i<8;i+=2)
	  fprintf(stderr, "return %d:%d\n",i,*((short*)(buffer+i)));
  }
  delete RFLab;
  return 0;
}
